Search for command history

Contents|Index|Previous|Next
Searching for commands in the history

Readline provides commands for searching through the command history for lines containing a specified string. There are two search modes: incremental and non-incremental.

Incremental searches begin before the user has finished typing the search string. As each character of the search string is typed, Readline displays the next entry from the history matching the string typed so far.

An incremental search requires only as many characters as needed to find the desired history entry. The Esc key is used to terminate an incremental search. C-j will also terminate the search. C-g will abort an incremental search and restore the original line. When the search is terminated, the history entry containing the search string becomes the current line. To find other matching entries in the history list, type C-s or C-r, as appropriate. This will search backward or forward in the history for the next entry matching the search string typed up to that point. Any other key sequence bound to a Readline command will terminate the search and execute that command. For instance, using the Return key will terminate the search and accept the line, thereby executing the command from the history list.

Non-incremental searches read the entire search string before starting to search for matching history lines. The search string may be typed by the user or be part of the contents of the current line.

Top|Contents|Index|Previous|Next